/*
 * @Author: PC9527\Jack sophia2152@qq.com
 * @Date: 2023-08-03 17:03:03
 * @LastEditors: PC9527\Jack sophia2152@qq.com
 * @LastEditTime: 2023-08-10 17:07:28
 * @Description:
 */
import { UsernameParams, UsernameListGetResultModel, AdminParams } from './model/adminModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  AdminList = '/system/admin/list',
  CreateAdmin = 'system/admin/create',
  UpdateAdmin = 'system/admin/update',
  DeleteAdmin = 'system/admin/delete',
  CheckUsername = '/system/admin/usernameExist',
}

export const getAdminList = (params: UsernameParams) =>
  defHttp.get<UsernameListGetResultModel>({ url: Api.AdminList, params });

export const createAdmin = (params: AdminParams) => defHttp.post({ url: Api.CreateAdmin, params });

export const updateAdmin = (id: number, params: AdminParams) =>
  defHttp.put({ url: `${Api.UpdateAdmin}/${id}`, params });

export const delAdmin = (id: number) => defHttp.delete({ url: `${Api.DeleteAdmin}/${id}` });

export const checkUsername = (username: string) =>
  defHttp.post({ url: Api.CheckUsername, params: { username } }, { errorMessageMode: 'none' });
